package com.xq.shop.po;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name="category")
public class Category {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	private Long parent_id;
	private String name;
	private Integer grade;
	private Integer seq;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable=false)
	private Date create_date = new Date();;
	private Date modify_date;
	
	@OneToMany(fetch=FetchType.LAZY)
	@Cascade(CascadeType.SAVE_UPDATE)
	@JoinColumn(name="category_id")
	private List<CategoryParam> params;
	
	public static final Integer Grade1 = 1;
	public static final Integer Grade2 = 2;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getParent_id() {
		return parent_id;
	}
	public void setParent_id(Long parentId) {
		parent_id = parentId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getGrade() {
		return grade;
	}
	public void setGrade(Integer grade) {
		this.grade = grade;
	}
	public Integer getSeq() {
		return seq;
	}
	public void setSeq(Integer seq) {
		this.seq = seq;
	}
	public Date getCreate_date() {
		return create_date;
	}
	public void setCreate_date(Date createDate) {
		create_date = createDate;
	}
	public Date getModify_date() {
		return modify_date;
	}
	public void setModify_date(Date modifyDate) {
		modify_date = modifyDate;
	}
	public List<CategoryParam> getParams() {
		return params;
	}
	public void setParams(List<CategoryParam> params) {
		this.params = params;
	}
}
